package com.ctshk.common.enums;

import java.util.Arrays;

/**
 * <p>
 * 订单付款状态枚举
 * </p>
 *
 * @author 胡广
 * @since 2021/2/26
 */
public enum OrderPaymentStatus {
    UN_PAYMENT(1, "待付款"),
    ALREADY_PAYMENT(2, "已付款"),
    ALREADY_CANCEL(3, "已取消");

    private Integer code;
    private String name;

    OrderPaymentStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 通过key拿订单状态名称
     * gzl-wansi001
     * @param code
     * @return
     */
    public static String getOrderPaymentStatusName(Integer code){
        OrderPaymentStatus orderPaymentStatus = Arrays.stream(OrderPaymentStatus.values())
                .filter(enums -> enums.getCode().equals(code)).findFirst().orElse(null);

        if(orderPaymentStatus != null){
            return orderPaymentStatus.getName();
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
